<?php
/*
 * index.action.php     Zhuayi 公共微博
 *
 * @copyright    (C) 2005 - 2010  zhuayi
 * @licenes      http://www.zhuayi.net
 * @lastmodify   2010-10-28
 * @author       zhuayi
 * @QQ			 2179942
 */
class publics_action extends zhuayi
{

	function __construct()
	{
		set_time_limit(0);
		parent::__construct();
		
		/* 验证登录 */
		//member_action::verify();
		
		$this->db = parent::db();
		
	}
	
	
	function index($api)
	{
		
		/* 取API */
		$api = $info = api_modle::api(array('api'=>$api));
		
		$class = $api['api'].'_action';
		
		$app = new $class('{"oauth_token":"13f4f70fc476d8320e390986620fd922","oauth_token_secret":"f09678110079b8d8f15a7ccba3f1576c","user_id":"1753070263"}');
		
		$reset = $app->public_timeline();
		
		$i=1;
		foreach ($reset as $val)
		{
			/* 插入数据 */
			$user = $app->fields($val['user']);
			$user['api'] = $api['id'];
			$uid = publics_modle::account_insert($user);
			
			$public['uid'] = $uid;
			$public['aid'] = $val['id'];
			$public['text'] = $val['text'];
			$public['litpic'] = $val['original_pic'];
			$public['api'] = $api['id'];
			$public['dtime'] = strtotime($val['created_at']);
			$public['text_md5'] = md5($val['text']);
			$reset = publics_modle::weibo_insert($public);
			
			if ($reset!='-1')
			{
				$i++;
			}
			
		}
		echo '--------------------------------------------------------------------'."\r\n";
		echo iconv('utf-8','gbk',' '.date("Y-m-d G:i:s").' 总计写入数据'.$i.'个'."\r\n");
		echo '--------------------------------------------------------------------'."\r\n";
	}
	

}
?>